package com.jframe.sso.action;

import java.util.ArrayList;
import java.util.List;

import com.jframe.sso.model.UserGroup;
import com.jframe.sso.service.UserGroupService;
import com.jframe.sys.controller.ExtendAction;
import com.jframe.sys.controller.utils.*;
import com.jframe.sys.utils.*;
import com.jframe.sys.webui.*;


public class UserGroupAction extends ExtendAction{
	
	private static String ACTION="userGroupAction";
	private static String SERVICE="userGroupService";
	private static Class<UserGroup> CLAZZ=UserGroup.class;
	
	public void list(){
		List<Columns> frozenColumns = new ArrayList<Columns>();//固定列
		List<Columns> commonColumns = new ArrayList<Columns>();
		frozenColumns.add(new Columns("ck","",40,""));
		commonColumns.add(new Columns("id", "编号", 100,""));
		commonColumns.add(new Columns("code", "权限代码", 100,""));
		commonColumns.add(new Columns("name","名称",120,""));
		commonColumns.add(new Columns("meno","描述",150,""));
		commonColumns.add(new Columns("active","有效否",100,new Editor("combobox",true),DicCache.getComboboxJson("dm_sys_active")));
		Grid grid = new Grid();
		grid.setUrl(ACTION+".do?method=load");
		String js = JsBuilder.getJsStr(frozenColumns, commonColumns, grid);
		this.request.setAttribute("js", js);
		this.forward("/jframe/sso/list/userGroupList.jsp");
	}
	
	public void load(){
		this.baseLoad(SERVICE, CLAZZ);
	}
	
	public void save(){
		this.baseSave(SERVICE, CLAZZ);
	}
	
	public void delete(){
		this.baseDelete(SERVICE);
	}
	
	public void getUserGroupById(){
		this.print(JsonUtil.obj2Json(this.getObject(SERVICE)));
	}
	
	public void getUserGroups(){
		UserGroupService userGroupService = (UserGroupService)this.getBean("userGroupService");
		List<UserGroup> ls = userGroupService.findList("where active=1 order by id");
		this.print(JsonUtil.list2Json(ls));
	}
	
}


